﻿using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Reflection;
using System.Windows;
using System.Windows.Threading;
using Castle.Core;
using Castle.MicroKernel.Registration;
using Milestone.ComponentModel;
using Topics.Radical;
using Topics.Radical.ComponentModel;
using Topics.Radical.ComponentModel.Messaging;
using Topics.Radical.Messaging;
using Topics.Radical.Windows.Presentation;
using Topics.Radical.Windows.Presentation.ComponentModel;
using Topics.Radical.Windows.Presentation.Services;
using Topics.Radical.Windows.Threading;

namespace Milestone.Boot.Installers
{
	/// <summary>
	/// A Windsor installer.
	/// </summary>
	[Export( typeof( IWindsorInstaller ) )]
	public class DefaultInstaller : IWindsorInstaller
	{
		/// <summary>
		/// Performs the installation in the <see cref="T:Castle.Windsor.IWindsorContainer"/>.
		/// </summary>
		/// <param name="container">The container.</param>
		/// <param name="store">The configuration store.</param>
		public void Install( Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store )
		{
			container.Register
			(
				AllTypes.FromThisAssembly()
					.IncludeNonPublicTypes()
					.BasedOn<IUserTask>()
					.Where( t => t.Namespace.IsLike( "*.Presentation.Tasks" ) && !t.IsAbstract && !t.IsInterface )
					.Configure( r => r.NonInjectable() )
			);
		}
	}
}